Skip to content

Instantly share code, notes, and snippets.

View CrypticMessenger's full-sized avatar
🧠
accelerating

Ankit Sharma CrypticMessenger

🧠
accelerating
View GitHub Profile
/**
* Iteration 3: Fine-Grained Safe Memoizer
* A thread-safe implementation of a memoizer that caches computed results using fine-grained locking.
* This implementation uses ConcurrentHashMap to allow concurrent access to the cache,
* enabling multiple threads to compute and cache results simultaneously without blocking each other.
*/
public class FineGrainedSafeMemoizer<A,V> implements Computable<A,V> {
private final ConcurrentHashMap<A,V> cache = new ConcurrentHashMap<>();
private final Computable<A,V> computable;
/**
* Iteration 2: Serialized Naive Safe Memoizer
* A thread-safe implementation of a memoizer that caches computed results.
* This implementation synchronizes the entire compute method, ensuring thread safety
* but potentially creating performance bottlenecks under high contention.
*/
public class SerializedNaiveSafeMemoizer<A,V> implements Computable<A,V> {
@GuardedBy("this") // documents that cache is protected by the intrinsic lock
private final Map<A,V> cache = new HashMap<>();
private final Computable<A,V> computable;
@CrypticMessenger
CrypticMessenger / UnsafeMemoizer.java
Last active September 30, 2025 18:45
UnsafeMemorizer
package concurrentcache.cache;
import java.util.HashMap;
import java.util.Map;
import concurrentcache.computable.Computable;
/**
* A basic memoization implementation that caches computed results.
* This implementation is not thread-safe and should not be used in concurrent environments.
@CrypticMessenger
CrypticMessenger / workfloadDescription.md
Created August 25, 2025 18:25
Workload descriptions
Service Description CPU Allocated Memory Allocated
Service 1 Compute-intensive (e.g., video processing) cpu1 mem1
Service 2 Memory-intensive (e.g., in-memory caching) cpu2 mem2
Service 3 Balanced (e.g., API server) cpu3 mem3
@CrypticMessenger
CrypticMessenger / compartiveAnalysis.csv
Last active June 21, 2025 14:52
Comparative analysis of Available solutions
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
"Setup Option","Cost","Data Control / Locality","Ability to Save Workflows","Ease of Use"
"Local: Docker + ngrok","Free (except PC resources; ngrok free tier)","Full local control; data stays on your machine unless accessed via ngrok tunnel","Full (persistent local storage; workflows, credentials, and history are saved on your disk)","Easy - after setup; Docker/CLI knowledge needed, ngrok setup adds a step"
"Local: Docker or npm","Free (except PC resources)","Full local control; all data is local","Full (persistent local storage)","Moderate; Docker or npm setup, but no public access to telegram or any external hooks"
"Online: Render or Railway (Free Tier)","Free (Render, limited free period for Railway)","Data hosted in cloud (Render/Railway); less control than local","Not persistent on free tier: Data and workflows may be lost if the instance is stopped, restarted, or deleted. Free databases on Render expire after 30–90 days; no backups","Easy; UI-based deployment, public URL, but must manage persistence ris