alecthomas

alecthomas

Member Since 12 years ago

Sydney, Australia

Experience Points
899
follower
Lessons Completed
5
follow
Lessons Completed
235
stars
Best Reply Awards
139
repos

2064 contributions in the last year

Pinned
⚡ A parser library for Go
⚡ Kong is a command-line parser for Go
⚡ A general purpose syntax highlighter in pure Go
⚡ Hermit manages isolated, self-bootstrapping sets of tools in software projects.
⚡ EntityX - A fast, type-safe C++ Entity-Component system
⚡ Python's repr() for Go
Activity
Dec
4
1 day ago
Activity icon
created tag

alecthomas in alecthomas/kong create tag v0.2.20

createdAt 8 hours ago
Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

Do not add environment variable to help it is already present

Fixes #246.

push

alecthomas push alecthomas/kong

alecthomas
alecthomas

Do not add environment variable to help it is already present.

Fixes #246.

commit sha: deebf0b09b7bdda61ec299ab90aaaa341436dd4b

push time in 9 hours ago
pull request

alecthomas pull request alecthomas/kong

alecthomas
alecthomas

Do not add environment variable to help it is already present

Fixes #246.

Activity icon
issue

alecthomas issue alecthomas/kong

alecthomas
alecthomas

Default help formatter appends environment variable even when ${env} is inside the help string

I have the following structure:

type Config struct {
	Project   string `short:"p" env:"CI_PROJECT_ID" help:"Environment variable: ${env}"`
}

And the help message I get is:

Environment variable: CI_PROJECT_ID ($CI_PROJECT_ID)

But I would expect it to be:

Environment variable: CI_PROJECT_ID

This issue is a followup to #244.

pull request

alecthomas merge to alecthomas/kong

alecthomas
alecthomas

Do not add environment variable to help it is already present

Fixes #246.

push

alecthomas push alecthomas/kong

alecthomas
alecthomas

Support $$ for escaping $ in interpolated values.

Fixes #248

commit sha: 32b2f740c921ebddcf8abe1a9f3ce781c25c93c2

push time in 18 hours ago
Activity icon
issue

alecthomas issue alecthomas/kong

alecthomas
alecthomas

Allow escaping $ inside a help string

So that one can use $${env} to get ${env} printed out.

Activity icon
created tag

alecthomas in alecthomas/assert create tag v2.0.0-alpha4

createdAt 1 day ago
Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

Do not add environment variable to help it is already present

Fixes #246.

alecthomas
alecthomas

Kong doesn't currently support escaping $, which is a bit of an issue, so I think that $$ could/should be the escaping system, yeah.

Activity icon
created branch

alecthomas in alecthomas/atomic create branch master

createdAt 1 day ago
Activity icon
created repository
createdAt 1 day ago
Activity icon
created tag

alecthomas in alecthomas/assert create tag v2.0.0-alpha3

createdAt 1 day ago
Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

Do not add environment variable to help it is already present

Fixes #246.

alecthomas
alecthomas

Thanks for the PR, but I think this change is too specific to this one problem. I think what I'd prefer, if you're willing to iterate, would be a new field OrigHelp which is just the original un-interpolated help string, and make the interpolateHasVar() function public for reuse as HasInterpolatedVar(). This will be general purpose enough so that the fields can be reused in the future for different purposes, while still fixing this issue.

Activity icon
issue

alecthomas issue comment alecthomas/entityx

alecthomas
alecthomas

Entity creation / destruction slows down over time?

I've found a very odd situation that I'm trying to troubleshoot right now using entityx.

I'm using OpenCV to detect and track objects from frame-to-frame in a video, and then using entityx to manage the physics of each tracked object. I've found that as my project runs, the framerate drops -- it starts at 60 fps, then within 30 minutes it's dropped down to 48 or so, and by the 90 minute mark it's barely hitting 20 fps. After several rounds of surgically removing / adding code back into the project to identify the issue, I've found that the creation / destruction of objects completely slows down the software:

void setup(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	mEntityHandle = parentDisplay->mEntities.create();
	mEntityHandle.assign<Id>(-1);
}

void update(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);

	if (mEntityHandle.valid()) {
		auto id_component = mEntityHandle.component<Id>();
		id_component->mId = getLabel();
	}
}

void destroy(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	entityx::ComponentHandle<sitara::Id> id;
	//entityx::ComponentHandle<sitara::ecs::Attractor> force;
	for (auto entity : parentDisplay->mEntities.entities_with_components(id)) {
		if (id->mId == getLabel()) {
			entity.destroy();
		}
	}
}

These three functions are simply hooks that are called by my object tracker, and input a void* display that represents the parent class of my entityx::EntityManager objects. But I've found that removing these few lines of code removes my slowdown problem completely, and re-adding them causes the issue I'm observing.

So my question is: what could possibly be causing this? While running in VS2019 I don't see any memory leaks (memory usage looks pretty steady); it could be that there's a very expensive memory alignment operations that occurs somewhere due to the constant destruction / creation of entities, but if so, I'm not sure how to compensate for it.

For further troubleshooting information, my Id Component is very simple:

	struct Id {
		Id(int id) {
			mId = id;
		}

		int mId;
	};

So I doubt that there's any issues with this being a very expensive operation...

alecthomas
alecthomas

No problem and good luck. I'd be interested in hearing what the cause was if/when you find it, just out of curiosity.

Activity icon
issue

alecthomas issue alecthomas/entityx

alecthomas
alecthomas

Entity creation / destruction slows down over time?

I've found a very odd situation that I'm trying to troubleshoot right now using entityx.

I'm using OpenCV to detect and track objects from frame-to-frame in a video, and then using entityx to manage the physics of each tracked object. I've found that as my project runs, the framerate drops -- it starts at 60 fps, then within 30 minutes it's dropped down to 48 or so, and by the 90 minute mark it's barely hitting 20 fps. After several rounds of surgically removing / adding code back into the project to identify the issue, I've found that the creation / destruction of objects completely slows down the software:

void setup(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	mEntityHandle = parentDisplay->mEntities.create();
	mEntityHandle.assign<Id>(-1);
}

void update(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);

	if (mEntityHandle.valid()) {
		auto id_component = mEntityHandle.component<Id>();
		id_component->mId = getLabel();
	}
}

void destroy(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	entityx::ComponentHandle<sitara::Id> id;
	//entityx::ComponentHandle<sitara::ecs::Attractor> force;
	for (auto entity : parentDisplay->mEntities.entities_with_components(id)) {
		if (id->mId == getLabel()) {
			entity.destroy();
		}
	}
}

These three functions are simply hooks that are called by my object tracker, and input a void* display that represents the parent class of my entityx::EntityManager objects. But I've found that removing these few lines of code removes my slowdown problem completely, and re-adding them causes the issue I'm observing.

So my question is: what could possibly be causing this? While running in VS2019 I don't see any memory leaks (memory usage looks pretty steady); it could be that there's a very expensive memory alignment operations that occurs somewhere due to the constant destruction / creation of entities, but if so, I'm not sure how to compensate for it.

For further troubleshooting information, my Id Component is very simple:

	struct Id {
		Id(int id) {
			mId = id;
		}

		int mId;
	};

So I doubt that there's any issues with this being a very expensive operation...

Dec
3
2 days ago
Dec
2
3 days ago
Activity icon
issue

alecthomas issue comment alecthomas/entityx

alecthomas
alecthomas

Entity creation / destruction slows down over time?

I've found a very odd situation that I'm trying to troubleshoot right now using entityx.

I'm using OpenCV to detect and track objects from frame-to-frame in a video, and then using entityx to manage the physics of each tracked object. I've found that as my project runs, the framerate drops -- it starts at 60 fps, then within 30 minutes it's dropped down to 48 or so, and by the 90 minute mark it's barely hitting 20 fps. After several rounds of surgically removing / adding code back into the project to identify the issue, I've found that the creation / destruction of objects completely slows down the software:

void setup(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	mEntityHandle = parentDisplay->mEntities.create();
	mEntityHandle.assign<Id>(-1);
}

void update(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);

	if (mEntityHandle.valid()) {
		auto id_component = mEntityHandle.component<Id>();
		id_component->mId = getLabel();
	}
}

void destroy(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	entityx::ComponentHandle<sitara::Id> id;
	//entityx::ComponentHandle<sitara::ecs::Attractor> force;
	for (auto entity : parentDisplay->mEntities.entities_with_components(id)) {
		if (id->mId == getLabel()) {
			entity.destroy();
		}
	}
}

These three functions are simply hooks that are called by my object tracker, and input a void* display that represents the parent class of my entityx::EntityManager objects. But I've found that removing these few lines of code removes my slowdown problem completely, and re-adding them causes the issue I'm observing.

So my question is: what could possibly be causing this? While running in VS2019 I don't see any memory leaks (memory usage looks pretty steady); it could be that there's a very expensive memory alignment operations that occurs somewhere due to the constant destruction / creation of entities, but if so, I'm not sure how to compensate for it.

For further troubleshooting information, my Id Component is very simple:

	struct Id {
		Id(int id) {
			mId = id;
		}

		int mId;
	};

So I doubt that there's any issues with this being a very expensive operation...

alecthomas
alecthomas

FWIW I ran the example for an hour and didn't see any slowdown at all, still a solid ~400fps 🤷‍♂️

Activity icon
issue

alecthomas issue comment alecthomas/entityx

alecthomas
alecthomas

Entity creation / destruction slows down over time?

I've found a very odd situation that I'm trying to troubleshoot right now using entityx.

I'm using OpenCV to detect and track objects from frame-to-frame in a video, and then using entityx to manage the physics of each tracked object. I've found that as my project runs, the framerate drops -- it starts at 60 fps, then within 30 minutes it's dropped down to 48 or so, and by the 90 minute mark it's barely hitting 20 fps. After several rounds of surgically removing / adding code back into the project to identify the issue, I've found that the creation / destruction of objects completely slows down the software:

void setup(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	mEntityHandle = parentDisplay->mEntities.create();
	mEntityHandle.assign<Id>(-1);
}

void update(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);

	if (mEntityHandle.valid()) {
		auto id_component = mEntityHandle.component<Id>();
		id_component->mId = getLabel();
	}
}

void destroy(void* display) {
	Display* parentDisplay = static_cast<Display*>(display);
	entityx::ComponentHandle<sitara::Id> id;
	//entityx::ComponentHandle<sitara::ecs::Attractor> force;
	for (auto entity : parentDisplay->mEntities.entities_with_components(id)) {
		if (id->mId == getLabel()) {
			entity.destroy();
		}
	}
}

These three functions are simply hooks that are called by my object tracker, and input a void* display that represents the parent class of my entityx::EntityManager objects. But I've found that removing these few lines of code removes my slowdown problem completely, and re-adding them causes the issue I'm observing.

So my question is: what could possibly be causing this? While running in VS2019 I don't see any memory leaks (memory usage looks pretty steady); it could be that there's a very expensive memory alignment operations that occurs somewhere due to the constant destruction / creation of entities, but if so, I'm not sure how to compensate for it.

For further troubleshooting information, my Id Component is very simple:

	struct Id {
		Id(int id) {
			mId = id;
		}

		int mId;
	};

So I doubt that there's any issues with this being a very expensive operation...

alecthomas
alecthomas

I'll run the example for an hour this morning to see what happens.

Wild question, but is it possible your machine is overheating?

Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

env interpolation does not seem to work

I have the following structure:

type Config struct {
	Project   string `short:"p" env:"CI_PROJECT_ID" help:"Environment variable: ${env}"`
}

When I try to use it, I get:

panic: help for --project=STRING: undefined variable ${env}

I am using kong v0.2.18.

alecthomas
alecthomas

For now just rely on the default formatter or pass in your own via options.

Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

env interpolation does not seem to work

I have the following structure:

type Config struct {
	Project   string `short:"p" env:"CI_PROJECT_ID" help:"Environment variable: ${env}"`
}

When I try to use it, I get:

panic: help for --project=STRING: undefined variable ${env}

I am using kong v0.2.18.

alecthomas
alecthomas
Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

env interpolation does not seem to work

I have the following structure:

type Config struct {
	Project   string `short:"p" env:"CI_PROJECT_ID" help:"Environment variable: ${env}"`
}

When I try to use it, I get:

panic: help for --project=STRING: undefined variable ${env}

I am using kong v0.2.18.

alecthomas
alecthomas

Ah it is not a trivial fix unfortunately. By the time DefaultHelpValueFormatter() is called ${env} has already been interpolated.

Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

env interpolation does not seem to work

I have the following structure:

type Config struct {
	Project   string `short:"p" env:"CI_PROJECT_ID" help:"Environment variable: ${env}"`
}

When I try to use it, I get:

panic: help for --project=STRING: undefined variable ${env}

I am using kong v0.2.18.

alecthomas
alecthomas

Hmm yeah, looks like it was accidentally removed in 7b000bd7. I'll add it back in.

Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

env interpolation does not seem to work

I have the following structure:

type Config struct {
	Project   string `short:"p" env:"CI_PROJECT_ID" help:"Environment variable: ${env}"`
}

When I try to use it, I get:

panic: help for --project=STRING: undefined variable ${env}

I am using kong v0.2.18.

alecthomas
alecthomas

It seems like a reasonable change to detect if the user has explicitly added ${env}/$env to the help string though, and in that case don't add it again.

Activity icon
issue

alecthomas issue comment alecthomas/kong

alecthomas
alecthomas

Fix that default should not override the placeholder

Fixes #243.

push

alecthomas push alecthomas/kong

alecthomas
alecthomas

Fix that default should not override the placeholder.

Fixes #243.

commit sha: c3703cda7ed1c641e57f986744370b28bbc67bda

push time in 2 days ago
Previous