Comments (23)
@Exocomp there are no maintainers in plural, only me sadly. I would however be very happy if someone would make a PR with those test cases. I recently had a kid and have had rather limited spare time.. I will get there and create those tests, but maybe not as soon as you'd like!
from hashids.net.
Hey everyone - the latest release 1.4.0 is now live: https://www.nuget.org/packages/Hashids.net/1.4.0
from hashids.net.
We use it in millions of calls every minute in a multithreaded app using a static singleton instance. It works fine as-is.
There are lots of other performance improvements that we made for allocations though in our internal fork but you should be fine as far as thread-safety.
from hashids.net.
@manigandham thanks for chiming in, that's reassuring.
For the library maintainers I suggest creating some test cases for thread safety of all the methods just be sure, the performance of a single instance is just too good just to limit this library to always create a new instance. It will only add to the awesomeness of this library.
from hashids.net.
@ullmark thank you for creating this library it is super useful! Congrats on your child and I absolutely understand regarding time. I'm super busy also but hopefully sometime in the future we can find some time.
from hashids.net.
@manigandham any chance of upstreaming some of those performance updates into this repo?
from hashids.net.
@MrSmoke Sure but it's been years since I worked on our fork and it needs to be redone with the latest language features.
@Daramant has an open PR for better performance right now: #37
from hashids.net.
So, the deal is that I don't really use windows much these last years, I'm going to see if I can get it running in macOs and .net core. Otherwise I might be able to remote to a windows computer.
Its great to hear @manigandham, but are there a way to really test thread safety? When this ticket came in I tried googling how to verify that in .net, but couldn't really find anything good?
I would gladly accept someone to contribute to this library and give push/publish access as well, as I've asked earlier.
from hashids.net.
You can test by creating new threads that call the same instance and use Thread.Join
to wait for the results. Add in some randomization to the loops and it should be enough for the logic being tested here.
Also the older target frameworks can probably be dropped since they're end of life already, and .NET Framework 4.8 is the last/latest Windows framework which already supports netstandard2.0
. This is the latest guidance: https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/cross-platform-targeting
I can help as a contributor, let me know
from hashids.net.
@manigandham I'll give you access! 👍
from hashids.net.
@ullmark Got it, thanks. I'll see what I can do in the next few days
from hashids.net.
I'd appreciate if you can confirm thread safety for this library, due to performance gains its worth using a single instance instead of just creating a new instance every time.
HashIds store simple data types inside and don't modify it. So, yes, it is thread safe.
Added thread safe test: 5e7d43d
from hashids.net.
hey @ullmark
I merged a bunch of bug fixes and improvements, updated tests, added the github actions workflow, and updated library version to 2.0.0. It should be ready for publishing to nuget. Let me know.
from hashids.net.
Hi, @manigandham, final optimizations: #43
from hashids.net.
@manigandham let me just briefly explain my thoughts on versioning of this library. This is initially a port of a javascript (or PHP whichever was first) library that now exists in 40+ languages. One of my friends built the Ruby version so I would say the code base is influenced by his port.
I tried to make build it by taking influences from JS to make sure that any changes to the algorithm could be made to .net version as easy as possible, ensuring that a hash created in one language could be used in another given the settings are the same.
At first I followed the versioning of the other libraries, but as where I added features like "long"-support that made no sense in for instance javascript, I started bumping minor version when I added non breaking stuff.
As for these updates I see no reason for updating major version since it doesn't have any breaking changes or big new features?
from hashids.net.
@ullmark Ah, thanks for the explanation - that makes sense. I'll merge in the new PR by @Daramant which made some more improvements in reducing allocations and will reset the version number to 1.4.0 (since we haven't published it yet).
from hashids.net.
@manigandham going to see if I can give you access to publish on nuget as well.
from hashids.net.
Impressive results from @Daramant
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|
RoundtripInts | 3.958 us | 0.0559 us | 0.0523 us | 0.0687 | - | - | 576 B |
RoundtripLongs | 4.546 us | 0.0470 us | 0.0439 us | 0.0687 | - | - | 576 B |
RoundtripHex | 4.095 us | 0.0503 us | 0.0470 us | 0.1755 | - | - | 1512 B |
Build and tests all pass: https://github.com/ullmark/hashids.net/runs/2411647475
@ullmark all set to release version 1.4.0
from hashids.net.
hi @ullmark are you still planning on publishing? anything I can do to help?
from hashids.net.
hi @manigandham. A question; Is there any way of using github for that, seeing a couple of new panels. Otherwise I could add so you have access publishing on nuget, what's your account there?
from hashids.net.
seeing microsoft now owns github right, it should be possible to setup something that deploys directly to nuget? (since I don't really use windows anymore... )
from hashids.net.
There's nothing automatic in github. It supports package hosting but separately from nuget. There are github actions that can push to nuget but I havent set that up before.
My nuget username is https://www.nuget.org/profiles/manigandham
from hashids.net.
@manigandham I created a new Organization called "hashids.net" on nuget where I also invited you as a collaborator. I removed myself as owner of the package and let the organization be the only owner.
I believe you should be able to publish new versions of the package now. Feel free to email me at [email protected] in the future if there is something you want to discuss. There is also a "hashids" organization on Github, I can ask them to invite you, but to be honest, not much is happening there 😄
from hashids.net.
Related Issues (20)
- Optimization: decode a single ID without allocating an array HOT 4
- how to Creates short unique ids from integers. (only positive numbers & zero) HOT 1
- Bug on long encoding with 16 alphabet chars HOT 8
- Using multiple options for encoding/decoding HOT 1
- Attempting to Decode short strings results in incorrect exceptions being produced HOT 7
- Hashids not generating with proper minhashlength HOT 1
- HashIds not working after adding custom Output formatter HOT 2
- How do I get HashIDs of a specific length? HOT 1
- How use id with Guid/UUID/Sequential Guid HOT 1
- Is there a guarantee of encoded sequence uniqueness with differing salts? HOT 4
- Insufficient Variation In Generated HashIds HOT 1
- Document the effective character limit of the salt HOT 5
- Decoding input smaller than minHashLength unhandled exceptions are thrown HOT 4
- Json support? HOT 3
- Regarding HashidsNet HOT 1
- Website seems down HOT 2
- Valid use-case for library? HOT 1
- Is this lib still being maintained? HOT 2
- Decode null string thows NullReferenceException HOT 1
- Same id generated for different integers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashids.net.